package com.lyc.mall.service.impl;

import com.lyc.mall.dao.OrdersDao;
import com.lyc.mall.model.BO.OrdersByPageBO;
import com.lyc.mall.model.VO.OrderOfOrdersByPageVO;
import com.lyc.mall.model.VO.OrdersByPageVO;
import com.lyc.mall.service.OrderService;
import com.lyc.mall.util.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class OrderServiceImpl implements OrderService {
    @Override
    public OrdersByPageVO ordersByPage(OrdersByPageBO ordersByPageBO) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        OrdersDao ordersDao = sqlSession.getMapper(OrdersDao.class);
        Integer total = ordersDao.queryCountByCondition(ordersByPageBO);
        List<OrderOfOrdersByPageVO> orders = ordersDao.queryOrdersByCondition(ordersByPageBO);
        sqlSession.commit();
        sqlSession.close();
        OrdersByPageVO ordersByPageVO = new OrdersByPageVO();
        ordersByPageVO.setTotal(total);
        ordersByPageVO.setOrders(orders);
        return ordersByPageVO;
    }
}
